﻿using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Project;
using NuGet.Enterprise.Package.Properties;
using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;

namespace NuGet.Enterprise.Package
{
    /// <summary>
    /// Creates Python Projects
    /// </summary>
    [Guid(AssemblyGuids.PackageProjectFactoryGuidString)]
    public sealed class PackageProjectFactory : ProjectFactory
    {
        private readonly PackageProjectPackage _package;

        /// <summary>
        /// Initializes a new instance of the <see cref="PackageProjectFactory"/> class.
        /// </summary>
        /// <param name="package">The package.</param>
        public PackageProjectFactory(PackageProjectPackage package)
            : base(package)
        {
            _package = package;
        }

        /// <summary>
        /// Creates the project.
        /// </summary>
        /// <returns></returns>
        protected override ProjectNode CreateProject()
        {
            var project = new PackageProjectNode((PackageProjectPackage)this.Package);

            project.SetSite((IOleServiceProvider)(((IServiceProvider)this.Package).GetService(typeof(IOleServiceProvider))));

            return project;
        }
    }
}
